

package galaxy.app.dispatch.executor;

import java.util.List;

import galaxy.app.Galaxy;
import galaxy.app.dispatch.disruptor.MessageThread;
import galaxy.app.event.EventSystem;
import galaxy.app.event.GameEvent;

/**
 */
public class GameEventExecutor implements BaseExecutor {

    GameEvent gevent;

    EventSystem event;

    public GameEventExecutor( GameEvent gevent) {
        this.gevent = gevent;
        this.event = Galaxy.systems().get(EventSystem.class);
    }

    @Override
    public int threadId() {
        return gevent.threadId;
    }

    @Override
    public int calcHash(List<MessageThread> list) {
        return (int) this.gevent.dispatchHash() % list.size();
    }

    @Override
    public void invoke() {
        event.execute(gevent);
    }
}
